﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleCasino
{
    public static class Draw
    {
        public static void DrawText(string text, Style style)
        {
            int x = style.point.x;
            int y = style.point.y;
            ConsoleColor forg = style.foregColor;
            ConsoleColor backg = style.backgColor;
            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = forg;
            Console.BackgroundColor = backg;
            Console.Write(text);
            DefaultColor();
        }
        public static void DefaultColor()
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Black;
        }
        public static void DrawMenu(Menu CurrentMenu)
        {
            //Draws the name in a set position. TODO: Maybe better way?
            Console.SetCursorPosition(Console.WindowWidth / 2 - 2, Console.WindowHeight / 2);
            Console.WriteLine(CurrentMenu.Name);
            for (int i = 0; i < CurrentMenu.MenuItems.Length; i++)
            {
                int x = CurrentMenu.MenuItems[i].Style.point.x;
                int y = CurrentMenu.MenuItems[i].Style.point.y;
                Console.SetCursorPosition(x, y);
                Console.WriteLine(CurrentMenu.MenuItems[i].Name);
                // If the MenuItem is the currently selected one, draws a curser under it.
                if (i == CurrentMenu.Selected)
                {
                    Console.SetCursorPosition(x, y + 2);
                    Console.WriteLine("*");
                }
            }
        }
    }
}
